using System;

namespace Comdiv{
    /// <summary>
    /// DateExtensions provides pseudo-nulls for DateTime, provides some
    /// extensions to manage it
    /// <remarks>
    /// usefull for DB-oriented applications, us substitution
    /// to real db-nulls and DateTime.Min-Max which interval
    /// is not supported by all rdbms
    /// </remarks>
    /// </summary>
    internal static class NullDate{
        /// <summary>
        /// Pseudo Null for Begin date, default to 1900-01-01, all
        /// dates that are less or equal 1900-01-01 are trated as
        /// logical null or you may treat it as minus unlimited for dates
        /// </summary>
        public static readonly DateTime Begin = new DateTime(1900, 1, 1);
        /// <summary>
        /// Pseudo Null for End date, default to 3000-01-01, all
        /// dates that are greater or equal 3000-01-01 are treated as
        /// logical null or you may treat it as plus unlimited for dates
        /// </summary>
        public static readonly DateTime End = new DateTime(3000, 1, 1);
        /// <summary>
        /// Checks if datetime is logical null 
        /// </summary>
        /// <param name="date">date to check</param>
        /// <returns>true if date &lt;= Begin or date &gt;= End</returns>
        public static bool isNull(this DateTime date){
            return date <= Begin || date >= End;
        }
        
    }
}